package hello;

import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;

@Configurable
@ComponentScan
public class Application {

    @Bean
    MessageService mockMessageServie(){
        return new MessageService() {
            @Override
            public String getMessage() {
                return "Hello~~";
            }
        };
    }

    public static void main(String[] args) {
        ApplicationContext context = new AnnotationConfigApplicationContext(Application.class);
//        String[] beanNames = context.getBeanDefinitionNames();
//        for (String s:beanNames){
//            System.out.println(s.toString());
//        }
        MessageService messageService = (MessageService)context.getBean("mockMessageServie");
        System.out.println(messageService.getMessage());
    }
}
